package com.lijiajia.cloud.resource.sys.client;

import com.lijiajia.cloud.service.order.test.TestService;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;

/**
 * description
 *
 * @author lijiajia
 * @since 2019-06-06
 */
@FeignClient(value = "cloud-order")
public interface TestClient extends TestService {

    @Slf4j
    class TestClientFallback implements TestClient{
        @Override
        public String test(String code) {
            log.warn("cloud-order test service fallback");
            return null;
        }
    }

    @Slf4j
    @Component
    class TestClientFallbackFactory implements FallbackFactory<TestClient> {

        @Override
        public TestClient create(Throwable cause) {
            log.warn("cloud-order testService fallbackFactory",cause);
            return code -> {
                log.warn("cloud-order test service fallback2");
                return null;
            };
        }
    }
}
